﻿using DFGK.IService;
using DFGK_WMS.Common;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace DFGK_WMS.WebAPI.Controllers.可视化大屏
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [ApiExplorerSettings(GroupName = "LS")]
    public class VisuallargeScreenController : BaseController
    {
        private readonly IVisuallargeScreenService visuallargeScreenService;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="environment"></param>
        /// <param name="visuallargeScreenService"></param>
        public VisuallargeScreenController(IWebHostEnvironment environment, IVisuallargeScreenService visuallargeScreenService) : base(environment)
        {
            this.visuallargeScreenService = visuallargeScreenService;
        }
        /// <summary>
        /// 待办已办任务统计
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetToDoDone(int pageIndex, int pageSize, int type)
        {
            int totalCount = 0;
            var list = visuallargeScreenService.GetToDoDone(pageIndex, pageSize, type, out totalCount);
            if (list != null || list.Count <= 0)
            {
                return Ok(BaseResult.Result(list, "查询成功！", "200"));
            }
            return Ok(BaseResult.Result(false, "查询失败！", "500"));
        }
        /// <summary>
        /// 月出入移盘统计
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetAllQty()
        {
            var list = visuallargeScreenService.GetAllQty();
            if (list != null)
            {
                return Ok(BaseResult.Result(list, "查询成功！", "200"));
            }
            return Ok(BaseResult.Result(false, "查询失败！", "500"));
        }
        /// <summary>
        /// 获取库存总数
        /// </summary>
        /// <returns>?</returns>s
        [HttpGet]
        public IActionResult GetInventoryQty()
        {
            var list = visuallargeScreenService.GetInventoryQty();
            if (list != null)
            {
                return Ok(BaseResult.Result(list, "查询成功！", "200"));
            }
            return Ok(BaseResult.Result(false, "查询失败！", "500"));
        }
        ///// <summary>
        ///// 根据质量等级查询
        ///// </summary>
        ///// <returns>?</returns>
        ///项目无质量字段使用
        //[HttpGet]
        //public IActionResult GetQtyByQualityState()
        //{
        //    var list = visuallargeScreenService.GetQtyByQualityState();
        //    if (list != null)
        //    {
        //        return Ok(BaseResult.Result(list, "查询成功！", "200"));
        //    }
        //    return Ok(BaseResult.Result(false, "查询失败！", "500"));
        //}
        /// <summary>
        /// 出入库数量统计
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetQtyByWork(string StartTime, string EndTime)
        {
            var list = visuallargeScreenService.GetQtyByWork(StartTime, EndTime);
            if (list != null)
            {
                return Ok(BaseResult.Result(list, "查询成功！", "200"));
            }
            return Ok(BaseResult.Result(false, "查询失败！", "500"));
        }
        /// <summary>
        /// 按装备大类统计
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetMaterialCategoryQty()
        {
            var list = visuallargeScreenService.GetMaterialCategoryQty();
            if (list != null)
            {
                return Ok(BaseResult.Result(list, "查询成功！", "200"));
            }
            return Ok(BaseResult.Result(false, "查询失败！", "500"));
        }
        /// <summary>
        /// 按器材分类统计
        /// </summary>
        /// <returns></returns>
        ///因为这个项目不涉及到MaterialGroupsQty表，表中无数据
        [HttpGet]
        public IActionResult GetMaterialGroupsQty()
        {
            var list = visuallargeScreenService.GetMaterialGroupsQty();
            if (list != null)
            {
                return Ok(BaseResult.Result(list, "查询成功！", "200"));
            }
            return Ok(BaseResult.Result(false, "查询失败！", "500"));
        }
        /// <summary>
        /// 大屏调拨/自购入库查询
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetMaterialTypeCount()
        {
            var list = visuallargeScreenService.GetMaterialTypeCount();
            if (list != null)
            {
                return Ok(BaseResult.Result(list, "查询成功！", "200"));
            }
            return Ok(BaseResult.Result(false, "查询失败！", "500"));
        }
        /// <summary>
        /// 器材入库统计
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetEquipmentReceiving()
        {
            var list = visuallargeScreenService.GetEquipmentReceiving();
            if (list != null)
            {
                return Ok(BaseResult.Result(list, "查询成功！", "200"));
            }
            return Ok(BaseResult.Result(false, "查询失败！", "500"));
        }
        /// <summary>
        /// 器材出库统计
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetEquipmentShipping()
        {
            var list = visuallargeScreenService.GetEquipmentShipping();
            if (list != null)
            {
                return Ok(BaseResult.Result(list, "查询成功！", "200"));
            }
            return Ok(BaseResult.Result(false, "查询失败！", "500"));
        }
        /// <summary>
        /// 今日数据
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetTodayData()
        {
            var list = visuallargeScreenService.GetTodayData();
            if (list != null)
            {
                return Ok(BaseResult.Result(list, "查询成功！", "200"));
            }
            return Ok(BaseResult.Result(false, "查询失败！", "500"));
        }
        /// <summary>
        /// 获取近7天的数据
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetSevenData()
        {
            var list = visuallargeScreenService.GetSevenData();
            if (list != null)
            {
                return Ok(BaseResult.Result(list, "查询成功！", "200"));
            }
            return Ok(BaseResult.Result(false, "查询失败！", "500"));
        }
        /// <summary>
        /// 获取近31天的数据
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetThirtyOneData()
        {
            var list = visuallargeScreenService.GetThirtyOneData();
            if (list != null)
            {
                return Ok(BaseResult.Result(list, "查询成功！", "200"));
            }
            return Ok(BaseResult.Result(false, "查询失败！", "500"));
        }
        /// <summary>
        /// 库房相关
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetWarehouseMsg()
        {
            var list = visuallargeScreenService.GetWarehouseMsg();
            if (list != null)
            {
                return Ok(BaseResult.Result(list, "查询成功！", "200"));
            }
            return Ok(BaseResult.Result(false, "查询失败！", "500"));
        }
        /// <summary>
        /// SKU
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetSKUMsg()
        {
            var list = visuallargeScreenService.GetSKUMsg();
            if (list != null)
            {
                return Ok(BaseResult.Result(list, "查询成功！", "200"));
            }
            return Ok(BaseResult.Result(false, "查询失败！", "500"));
        }
        /// <summary>
        /// 仓库利用率
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetWarehoustUtilization()
        {
            var list = visuallargeScreenService.GetWarehoustUtilization();
            if (list != null)
            {
                return Ok(BaseResult.Result(list, "查询成功！", "200"));
            }
            return Ok(BaseResult.Result(false, "查询失败！", "500"));
        }
        /// <summary>
        /// 近30天仓库单量走势
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetWarehouseTrend()
        {
            var list = visuallargeScreenService.GetWarehouseTrend();
            if (list != null)
            {
                return Ok(BaseResult.Result(list, "查询成功！", "200"));
            }
            return Ok(BaseResult.Result(false, "查询失败！", "500"));
        }
        ///// <summary>
        ///// 近30天仓库出货量-根据仓库查
        ///// </summary>
        ///// <returns></returns>
        ///并没有使用到库房
        //[HttpGet]
        //public IActionResult GetWarehouseShippingQty()
        //{
        //    var list = visuallargeScreenService.GetWarehouseShippingQty();
        //    if (list != null)
        //    {
        //        return Ok(BaseResult.Result(list, "查询成功！", "200"));
        //    }
        //    return Ok(BaseResult.Result(false, "查询失败！", "500"));
        //}
        /// <summary>
        /// 实时库存
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetInventory()
        {
            var list = visuallargeScreenService.GetInventory();
            if (list != null)
            {
                return Ok(BaseResult.Result(list, "查询成功！", "200"));
            }
            return Ok(BaseResult.Result(false, "查询失败！", "500"));
        }
    }
}
